package com.example.demo.model;

import com.baidu.bas.annotation.Erupt;
import com.baidu.bas.annotation.EruptField;
import com.baidu.bas.annotation.config.SkipSerialize;
import com.baidu.bas.annotation.model.TableLogic;
import com.baidu.bas.annotation.sub_field.Edit;
import com.baidu.bas.annotation.sub_field.EditType;
import com.baidu.bas.annotation.sub_field.View;
import com.baidu.bas.annotation.sub_field.sub_edit.Search;
import com.baidu.bas.upms.model.base.HyperModel;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.vladmihalcea.hibernate.type.json.JsonStringType;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.TypeDef;

import javax.persistence.*;

/**
 * @author liuzhenchuan@foxmail.com
 * @date 2020/12/21
 */
@Erupt(name = "营销任务模板")
@Table(name = "ma_graph_task_template")
@Entity
@TypeDef(name = "json", typeClass = JsonStringType.class)
@Getter
@Setter
public class GraphTaskTemplate extends HyperModel {
    /**
     * name
     */
    @EruptField(
            views = @View(title = "名称"),
            edit = @Edit(title = "名称")
    )
    private String name;

    @EruptField(
            views = @View(title = "描述"),
            edit = @Edit(title = "描述")
    )
    private String description;

    @EruptField(
            views = @View(title = "任务"),
            edit = @Edit(title = "任务")
    )
    @OneToOne(cascade = CascadeType.ALL)
    private GraphTask graphTask;

    @ManyToOne
    @EruptField(
            views = @View(title = "分组", column = "name"),
            edit = @Edit(title = "分组", type = EditType.REFERENCE_TABLE, search = @Search)
    )
    private Group group;

    @Column
    @TableLogic
    @JsonIgnore
    @SkipSerialize
    private Short removed;

}
